package group2assignone.ucm.manager;

import group2assignone.func.Authentication;
import group2assignone.func.UCCtoALAdapter;
import group2assignone.model.Manager;
import group2assignone.ucm.UCController;
import group2assignone.view.MainView;
import group2assignone.view.manager.ManagerView;

/**
 * Use Case controller to login a manager
 * @author group2
 */
public class UCManagerLogin implements UCController {

    private Manager man;
    private ManagerView manView;
    private MainView view;
    private Authentication auth;
    private boolean ok;

    /**
     * sets the view
     * @param view
     */
    public UCManagerLogin(MainView view) {
        this.view = view;
    }

    @Override
    public void run() {
        man = new Manager();
        auth = new Authentication();
        view.upload(man);
        ok = auth.authManager(man);
        if (ok) {
            UCUIManagerMainView uc = new UCUIManagerMainView(man);
            uc.run();
//            manView = ManagerView.getInstance();
//            manView.setUsername(man.getUsername());
//
//            manView.go();

//            UCManagerUICreateFlight umlc = new UCManagerUICreateFlight();
//            manView.setCreateFlightAL(new UCCtoALAdapter(umlc));
//
//            UCManagerUIEditFlight umle = new UCManagerUIEditFlight();
//            manView.setEditFlightAL(new UCCtoALAdapter(umle));
//
//            UCManagerUIDeleteFlight umld = new UCManagerUIDeleteFlight();
//            manView.setDeleteFlightAL(new UCCtoALAdapter(umld));
//
//            UCManagerUIAddAirport umaa = new UCManagerUIAddAirport();
//            manView.setAddAirportAL(new UCCtoALAdapter(umaa));
//
//            UCManagerUIEditAirport umea = new UCManagerUIEditAirport();
//            manView.setEditAirportAL(new UCCtoALAdapter(umea));
//
//            UCManagerUIDeleteAirport umda = new UCManagerUIDeleteAirport();
//            manView.setDeleteAirportAL(new UCCtoALAdapter(umda));
//
//            UCManagerLogout uml = new UCManagerLogout();
//            manView.setLogoutAL(new UCCtoALAdapter(uml));

            view.dispose();
        }
    }
}
